package com.example.bobo.yuejian322.Adapter;


import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.bobo.yuejian322.Fragment.ViewHolder.Shaitu_Comment_ViewHolder;
import com.example.bobo.yuejian322.Fragment.ViewHolder.ZhuYe_MasterVierHolder;
import com.example.bobo.yuejian322.R;
import com.example.bobo.yuejian322.bean.Master;
import com.example.bobo.yuejian322.bean.ShaituDetial;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

public class Shaitu_comment_Adapter extends RecyclerView.Adapter    {

    //内部内List
    private List<ShaituDetial.CommentEntity> shaituDetialList= new ArrayList<>();
    private Context context;//上下文对象
    private LayoutInflater layoutInflater;
    //构造函数
    public Shaitu_comment_Adapter(Context context, List<ShaituDetial.CommentEntity>shaituDetialList){

        this.context=context;//保存上下文
        layoutInflater=LayoutInflater.from(context);
        this.shaituDetialList.addAll(shaituDetialList);//显示数据
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_shaitu_commnet,parent,false);
        Shaitu_Comment_ViewHolder holder=new Shaitu_Comment_ViewHolder(itemView);
        return holder;
    }
    //绑定数据
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

        Shaitu_Comment_ViewHolder shaitu_comment_viewHolder = (Shaitu_Comment_ViewHolder) holder;
        ShaituDetial.CommentEntity  shaituDetial = shaituDetialList.get(position);



        //获取具体的数据值

        String reply = shaituDetial.getReply();
        String time = shaituDetial.getReply_time();


        //绑定数据
        shaitu_comment_viewHolder.reply.setText(reply);
        shaitu_comment_viewHolder.time.setText(time);



        //页面跳转
        shaitu_comment_viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              /*  Intent intent = new Intent(context, FoodListActivity.class);
                //传值
                intent.putExtra("phonenum", phone);
                intent.putExtra("shop_id", shopId);
                intent.putExtra("shop_name", shopName);
                //在适配器里调用StarActivity方法
                context.startActivity(intent);*/

            }
        });

    }

    //显示条目的数量
    @Override
    public int getItemCount() {
        return shaituDetialList.size();
    }


}
